home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_all.zip
/
TI161.ASC
< prev
next >
Wrap
Text File
|
1992-09-02
|
6KB
|
199 lines
PRODUCT : TURBO PASCAL NUMBER : 161
VERSION : 2.0xx, 3.0xx
OS : MSDOS
DATE : March 13, 1986 PAGE : 1/3
TITLE : MEMORY MAP INFORMATION
1. When TURBO.COM is executed, MS-DOS builds a program segment
prefix in the lower 100H bytes of memory, and loads the
code immediately above. MS-DOS then jumps to CS: 100H. When
Turbo Pascal gains control, it sets the DS register to point
at the fir
In systems with little RAM, Memtop-DS may be less than 1000H
(64K bytes), and in that case SS is set to the same
paragraph address as DS and SP is set to (Memtop-DS)?16. In
the maps that follow we assume that Memtop-DS is greater
than 1000H.
When using the Editor, memory is mapped as follows:
CS:0000 - CS:00FF MS-DOS PROGRAM SEGMENT PREFIX
CS:0100 - CS:E0RC RUN-TIME LIBRARY CODE
CS:E0RC - CS:E0CC MONITOR, EDITOR AND COMPILER CODE
DS:0000 - DS:E0RW RUN-TIME LIBRARY DATA
DS:E0RW - DS:E0CW MONITOR, EDITOR AND COMPILER DATA
DS:E0CW - DS:EOEM ERROR MESSAGES (IF LOADED)
DS:E0EM - DS:???? SOURCE TEXT
SS:???? - SS:FFFF CPU STACK
When the compiler is invoked to compile a program in memory,
it creates a new code segment immediately above the source
text. The PSP (Program Segment Prefix) and the run-time
library are copied from Turbo Pascal's code segment. The
reason Turbo Pasc
CS:0000 - CS:00FF MS-DOS PROGRAM SEGMENT PREFIX
CS:0100 - CS:E0RC RUN-TIME LIBRARY CODE
CS:E0RC - CS:E0CC MONITOR, EDITOR AND COMPILER CODE
DS:0000 - DS:E0RW RUN-TIME LIBRARY DATA
DS:E0RW - DS:EOCW MONITOR, EDITOR AND COMPILER DATA
DS:E0CW - DS:E0EM ERROR MESSAGES (IF LOADED)
DS:O0EM - DS:EOST SOURCE TEXT
CP:0000 - CP:00FF MS-DOS PROGRAM SEGMENT PREFIX (COPY)
CP:0100 - CP:E0RC RUN-TIME LIBRARY CODE (COPY)
CP:E0RC - CP:???? PROGRAM CODE
SS:???? - SS:FC00 SYMBOL TABLE
SS:???? - SS:FFFF CPU STACK
PRODUCT : TURBO PASCAL NUMBER : 161
VERSION : 2.0xx, 3.0xx
OS : MSDOS
DATE : March 13, 1986 PAGE : 2/3
TITLE : MEMORY MAP INFORMATION
To execute the finished program, Turbo Pascal simply does a
far jump to offset 100H in the new program segment (CP). It
will then look to the program as if it had been executed
from MS-DOS.
When a Turbo Pascal program is executed in memory or from
MS-DOS, it maps memory as shown below:
CS:0000 - CS:00FF MS-DOS PROGRAM SEGMENT PREFIX (COPY)
CS:0100 - CS:E0RC RUN-TIME LIBRARY CODE (COPY)
CS:E0RC - CS:E0PC PROGRAM CODE
DS:0000 - DS:E0RW RUN-TIME LIBRARY DATA
DS:E0RW - DS:E0PW PROGRAM DATA
HS:0000 - ??????? HEAP (TOP ADDRESS IN HEAPPTR)
SS:???? - SS:FFFF CPU STACK
On entry, DS is set to point just above the code segment,
and the heap pointer (HeapPtr) is set to point just above
the data segment. SS:SP is set to point at top of memory,
using the same technique as when Turbo Pascal itself is
executed.
When a program terminates, it either returns to MS-DOS
(using system function 0) or it does a far jump back to
Turbo Pascal, depending on a flag in the program code.
Typed constants are stored in the code segment and, except
for their base segment (CS versus DS), correspond to
variables in all aspects. Untyped constants are never stored
in the sense that they have a fixed address somewhere in
memory. An untyped con
2. There is no recursion stack in the 16-bit versions of Turbo
Pascal. It is only in the 8-bit version that the CPU stack
and the recursion stack are separated. The 16-bit version
implements a true "stack frame" concept, meaning that all
local variable
3. The CSEG, DSEG, and SSEG return the contents of the CS, DS,
and SS Registers, respectively. However, contrary to the
other segment registers, the value of the ES register is not
fixed. Turbo Pascal will initialize it when it uses it. ES
is used heav
PRODUCT : TURBO PASCAL NUMBER : 161
VERSION : 2.0xx, 3.0xx
OS : MSDOS
DATE : March 13, 1986 PAGE : 3/3
TITLE : MEMORY MAP INFORMATION
4. The fields of the PSP are easily accessed by declaring them
as absolute variables in the code segment. For instance:
var CMDLine: String(127) absolute CSeg:$80H
which declares a variable to access the command line passed
by MS-DOS in the PSP.
The chain and execute procedures store 0FF in the byte at
CS:80H to indicate that the program was invoked from another
program and not from MS-DOS. Otherwise, the PSP is not
changed during a chain/execute operation. Turbo Pascal only
accesses the PSP
5. There is no official way to catch run-time errors in the
current versions of Turbo Pascal.
6. When a COM File is invoked from MS-DOS, all segment
registers are set to point at the program segment prefix.
This initial value is retained in the CS register during
execution, and you can obtain it through the CSEG function.
7. Turbo Pascal initializes the divide-by-zero interrupt vector
(Interrupt 0). When the U compiler option is activated with
an {$U+} directive, Turbo Pascal initializes interrupt
vector 3 to point at a Ctrl-C check routine. In both cases,
MS-DOS syst
8. There is no additional information available on the inner
workings of the Turbo Pascal initialization routines (front
end). However, most if not all of the tasks carried out by
it are covered in the reference manual and the above
answers.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.